package com.cloudkinto.enumType.order.outbound;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.cloudkinto.vo.common.CommonKvVo;

import java.util.ArrayList;

/**
 * 出库目的地类型
 *
 * @author long
 */

public enum DestinationTypeEnum implements IEnum<Integer> {

    /**
     * 1药妆店 2经销商 3FBA 4三方仓
     */
    one(1, "药妆店"),
    two(2, "经销商"),
    three(3, "FBA"),
    four(4, "三方仓");

    private final Integer value;

    private final String desc;

    DestinationTypeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public Integer getValue() {
        return value;
    }

    public static ArrayList<CommonKvVo> getInboundTypeList() {
        ArrayList<CommonKvVo> list = new ArrayList<>();
        for (DestinationTypeEnum inboundType : values()) {
            list.add(
                    CommonKvVo.builder()
                            .label(inboundType.desc)
                            .value(inboundType.getValue())
                            .build()
            );
        }
        return list;
    }

    public static String getDescByVal(Integer value) {
        for (DestinationTypeEnum destinationTypeEnum : values()) {
            if (destinationTypeEnum.value.equals(value)) {
                return destinationTypeEnum.desc;
            }
        }
        return null;
    }

    public static Integer getValByDesc(String desc) {
        for (DestinationTypeEnum destinationTypeEnum : values()) {
            if (destinationTypeEnum.desc.equals(desc)) {
                return destinationTypeEnum.value;
            }
        }
        return null;
    }
}
